﻿using PRO.DbProvider;
using PRO.Entity;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using PRO.ORM;
using System.Data;
using System.Data.Common;

namespace PRO.Data.SqlServer
{
    public partial class DataProvider : IDataProvider
    {
        public DataTable GetAdminInfo(string username)
        {
            SqlHelper helper = new SqlSelect("Pro_Admin");
            AdminInfo info=new AdminInfo();
            helper.AddEntity(info,"");
            helper.AddWhereAnd("username", username, SqlDbType.NVarChar, 50, "=");
            return (DataTable)helper.Run();
        }
        public bool RePwd(int id, string oldpwd, string newpwd)
        {
            DbParameter[] prams = {
                                     DbHelper.MakeInParam("@id",(DbType)SqlDbType.Int,4,id),
									 DbHelper.MakeInParam("@oldpwd",(DbType)SqlDbType.NVarChar,100,oldpwd),
                                     DbHelper.MakeInParam("@newpwd",(DbType)SqlDbType.NVarChar,100,newpwd)
								  };
            string sql = "update Pro_Admin set pwd=@newpwd where id=@id and pwd=@oldpwd";
            return Convert.ToBoolean(DbHelper.ExecuteNonQuery(CommandType.Text, sql, prams));
        }
    }
}
